#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>


#define BUFF_LEN 100

#include "mychar.h"


int main(int argc, char *argv[]){
	int fd = -1;
	char buff[BUFF_LEN] = "";
	int maxLen = 0;
	int curLen = 0;

	if(argc < 2){
		printf("too few arguments\n");
		return 1;
	}

	//fd = open(argv[1], O_RDWR);
	fd = open(argv[1], O_RDWR | O_NONBLOCK);

	if(fd < 0){
		printf("open failed : %s \n", argv[1]);
		return 2;
	}

	
	//读数据
	int ret = read(fd, buff, 100);
	if(ret < 0){
		printf(" read failed ... NON_BLOCK\n");
	}
	printf("buff = %s\n", buff);

	close(fd);
	return 0;
}
